package com.ruoyi.appVersion.controller;

import com.ruoyi.appVersion.domain.AppVersion;
import com.ruoyi.appVersion.domain.AppVersionVo;
import com.ruoyi.appVersion.service.IAppVersionService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.alone.LonelyData;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ro.domain.goods;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 脚本版本Controller
 * 
 * @author ruoyi
 * @date 2022-06-06
 */
@Api("APP版本检测")
@RestController
@RequestMapping("/app/version")
public class AppVersionApiController extends BaseController
{


    @Autowired
    private IAppVersionService appVersionService;
    /**
     * 检查版本更新
     */
    @ApiOperation("检查版本更新")
    @GetMapping("/check")
    public LonelyData<AppVersionVo> list(@RequestParam(value = "package") String appName,@RequestParam(value = "ver")  Integer ver)
    {
        LonelyData<AppVersionVo> result=new LonelyData<>();
        AppVersion appVersion = appVersionService.getAppUpdate(appName,ver);
        AppVersionVo appVersionVo=new AppVersionVo();
        appVersionVo.setApkurl(appVersion.getApkurl());
        appVersionVo.setContent(appVersion.getContent());
        appVersionVo.setScripturl(appVersion.getScripturl());
        appVersionVo.setUpdate(appVersion.getUpdateType());
        return result.success(appVersionVo);
    }
}
